#include <stdio.h>

void escape(char s[], char t[])
{
    int i, j;
    for (i = j = 0; t[i] != '\0'; i++){
        switch (t[i]){
            case '\n':
                s[j++] = '\\';
                s[j++] = 'n';
                break;
            case '\t':
                s[j++] = '\\';
                s[j++] = 't';
                break;
            default:
                s[j++] = t[i];
                break;
        }
    }
    s[j] = '\0';
}

void unescape(char s[], char t[])
{
    int i, j;
    for (i = j = 0; t[i] != '\0'; i++){
        switch (t[i]){
            case '\\':
                if (t[i + 1] =='n')
                    s[j++] = '\n';
                else
                    s[j++] = '\t';
                i++;
                break;
            default:
                s[j++] = t[i];
                break;
        }
    }
    s[j] = '\0';
}

int main()
{
    char str1[20];
    char str2[20] ="abc     33";
    char str3[30];
    escape(str1, str2);
    printf("%s\n", str1);
    unescape(str3, str1);
    printf("%s\n", str3);

}
